#include "ItemDelegate.h"


ItemDelegate::ItemDelegate(ItemModel *a, QObject *parent):
    QStyledItemDelegate(parent)
{
    this->m_seamListViewModel=a;
    body=new ItemBody;
}

void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    if(index.column()==0)
        {
            SeamTask *data=m_seamListViewModel->at(index.row());
            if(data!=NULL){
                body->setName(data->seamname);
                body->setStatus(data->status);
                body->resize(option.rect.width(), 20);
                QPixmap pixmap=body->grab();
                painter->drawPixmap(option.rect, pixmap);
                return;
            }
        }
        QStyledItemDelegate::paint(painter, option, index);
}
